import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: '/login'
  },
  {
    path: '/index',
    name: 'index',
    component: () => import('../views/IndexView.vue'),
    children: [
      {
        path: '/',
        name: 'index',
        redirect: '/home'
      },
      {
        path: '/home',
        name: 'home',
        component: () => import('../views/ChildIndexView.vue')

      },
      {
        path: '/user',
        name: 'user',
        component: () => import('../views/UserView.vue')
      },
      {
        path: '/cart',
        name: 'cart',
        component: () => import('../views/CartView.vue')
      },
    ]
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/RegisterView.vue')
  },
  {
    path: '/admin',
    name: 'admin',
    component: () => import('../views/AdminView.vue'),
    children: [
      {
        path: '/AdminUser',
        name: 'AdminUser',
        component: () => import('../views/admin/AdminUser.vue')
      },
      {
        path: '/user',
        name: 'user',
        component: () => import('../views/UserView.vue')
      },
      {
        path: '/AdminBook',
        name: 'AdminBook',
        component: () => import('../views/admin/AdminBook.vue')
      },
      {
        path: '/AdminOrder',
        name: 'AdminOrder',
        component: () => import('../views/admin/AdminOrder.vue')
      },
    ]
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
